// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 .
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : apb_ready_drv.sv
// Author        : 
// Created On    : 2022-08-25 17:36
// Last Modified : 
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

`ifndef __APB_READY_DRV_SV__
`define __APB_READY_DRV_SV__

class apb_ready_drv extends uvm_component;
	virtual apb_interface vif;
	
	`uvm_component_utils(apb_ready_drv)
	
	extern function new(string name = "apb_ready_drv", uvm_component parent=null);
	extern virtual function void build_phase(uvm_phase phase);
	extern virtual task run_phase(uvm_phase phase);
endclass: apb_ready_drv

function apb_ready_drv::new(string name = "apb_ready_drv", uvm_component parent=null);
	super.new(name, parent);
endfunction: new

function void apb_ready_drv::build_phase(uvm_phase phase);
	super.build_phase(phase);
	`uvm_info("apb_ready_drv", "build_phase is called", UVM_LOW);
	if(!uvm_config_db #(virtual apb_interface)::get(this, "", "vif", vif))begin
		`uvm_fatal("apb_ready_drv", "virtual interface get fatal");
	end
endfunction: build_phase

task apb_ready_drv::run_phase(uvm_phase phase);
	fork 
		while(1)begin
            @this.vif.slave_cb;
            this.vif.pready  = 1'b1;
            this.vif.prdata  = $urandom();
            this.vif.pslverr = '0;
        end
	join_none
endtask: run_phase

`endif
